#include "Velocity.h"
#include <math.h>

Velocity::Velocity() {
}

Velocity::Velocity(double xComponent,double yComponent) {
	this->setXComponent(xComponent);
	this->setYComponent(yComponent);
}

double Velocity::getXComponent(){
	return this->xComponent;
}

double Velocity::getYComponent(){
	return this->yComponent;
}

void Velocity::setXComponent(double xComponent){
	this->xComponent = xComponent;
}

void Velocity::setYComponent(double yComponent){
	this->yComponent = yComponent;
}

Velocity::~Velocity() {
}

double Velocity::getModule(){
	double v = pow((float)( pow((float)xComponent,2) + pow((float)yComponent,2) ), 0.5f);
	return v;
}

void Velocity::setModule( double module ){
	double v = pow((float)( pow((float)xComponent,2) + pow((float)yComponent,2) ), 0.5f);
	double dx = xComponent/v;
	double dy = yComponent/v;

	xComponent = dx*module;
	yComponent = dy*module;
}